package org.example.everyday;

import java.util.Map;

/**
 * <p>
 * Description:TODO 详细描述
 * <p>
 * <p>
 *
 * @author anlu
 * @date 2022/6/27 8:39
 */
public class Lc522 {
    public static void main(String[] args) {
        Lc522 lc522 = new Lc522();
        String[] nums = {"aba","cdc","eae"};
        int res = lc522.findLUSlength(nums);
        System.out.println(res);

    }
    public int findLUSlength(String[] strs) {
        int n = strs.length;
        int ans = -1;
        for (int i = 0; i < n; i++) {
            boolean check = true;
            for (int j = 0; j < n; j++) {
                if(i != j &&  isSubseq(strs[i],strs[j])){
                    check = false;
                    break;
                }
            }
            if(check){
                ans = Math.max(ans, strs[i].length());
            }
        }
        return ans;
    }

    public boolean isSubseq(String s, String t){
        int ptS = 0, ptT = 0;
        while (ptS < s.length() && ptT < t.length()){
            if(s.charAt(ptS) == t.charAt(ptT)){
                ++ptS;
            }
            ++ptT;
        }
        return ptS == s.length();
    }
}
